---
title: "T2_analyses"
output: html_document
---

```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
library(psych)
library(dplyr)
library(rstatix)
library(ggplot2)
library(jtools)
library(interactions)
library(ggpubr)
library(tidyr)
data <- read.csv("part1_data_raw_T1T2.csv")
describe(data$age) #range 18-61, M=25.27, SD = 6.87
table(data$gender) #96 male, 90 female, 4 non-binary/other
table(data$ethnic) #94 white, 66 hispanic, 30 black, 1 asian, 1 middle eastern
```

### Creating Subscales - ALL PARTICIPANTS
```{r}
#FNE
#reverse code
data$FNE_2 <- 6-data$FNE_2 
data$FNE_4 <- 6-data$FNE_2 
data$FNE_7 <- 6-data$FNE_2 
data$FNE_10 <- 6-data$FNE_2 

#scale
data$FNE <- data %>% select(FNE_1:FNE_12) %>% rowMeans(na.rm=T)
describe(data$FNE)
FNE <- data %>% select(FNE_1:FNE_12)
psych::alpha(FNE)

#social support for secret
data$socsup <- data %>% select(soc_support_1:soc_support_6) %>% rowMeans(na.rm=T)
describe(data$socsup)
socsup <- data %>% select(soc_support_1:soc_support_6)
psych::alpha(socsup)

#authenticity
data$authenscale <- data %>% select(authen_scale_1:authen_scale_4) %>% rowMeans(na.rm=T)
describe(data$authenscale)
authenscale <- data %>% select(authen_scale_1:authen_scale_4)
psych::alpha(authenscale)

data$T2authenscale <- data %>% select(T2authen_scale_1:T2authen_scale_4) %>% rowMeans(na.rm=T)
describe(data$T2authenscale)
T2authenscale <- data %>% select(T2authen_scale_1:T2authen_scale_4)
psych::alpha(T2authenscale)

#relationship satisfaction
data$relsatis <- data %>% select(rel_satisf_1:rel_satisf_5) %>% rowMeans(na.rm=T)
describe(data$relsatis)
relsatis <- data %>% select(rel_satisf_1:rel_satisf_5)
psych::alpha(relsatis)
describe(data$intimacy_1)
describe(data$T2intimacy_1)

data$T2relsatis <- data %>% select(T2rel_satisf_1:T2rel_satisf_5) %>% rowMeans(na.rm=T)
describe(data$T2relsatis)
T2relsatis <- data %>% select(T2rel_satisf_1:T2rel_satisf_5)
psych::alpha(T2relsatis)

#anxiety
data$anxious <- data %>% select(anxdep_1:anxdep_6) %>% rowMeans(na.rm=T)
describe(data$anxious)
anxious <- data %>% select(anxdep_1:anxdep_6)
psych::alpha(anxious)

data$T2anxious <- data %>% select(T2anxdep_1:T2anxdep_6) %>% rowMeans(na.rm=T)
describe(data$T2anxious)
T2anxious <- data %>% select(T2anxdep_1:T2anxdep_6)
psych::alpha(T2anxious)

#depressed
data$depress <- data %>% select(anxdep_7:anxdep_12) %>% rowMeans(na.rm=T)
describe(data$depress)
depress <- data %>% select(anxdep_7:anxdep_12)
psych::alpha(depress)

data$T2depress <- data %>% select(T2anxdep_7:T2anxdep_12) %>% rowMeans(na.rm=T)
describe(data$T2depress)
T2depress <- data %>% select(T2anxdep_7:T2anxdep_12)
psych::alpha(T2depress)

#flourish
data$flourish <- data %>% select(flourish_1:flourish_8) %>% rowMeans(na.rm=T)
describe(data$flourish)
flourish <- data %>% select(flourish_1:flourish_8)
psych::alpha(flourish)

data$T2flourish <- data %>% select(T2flourish_1:T2flourish_8) %>% rowMeans(na.rm=T)
describe(data$T2flourish)
T2flourish <- data %>% select(T2flourish_1:T2flourish_8)
psych::alpha(T2flourish)

#burden scale
#reverse code
data$distant <- 8-data$distant
data$interact_diff <- 8-data$interact_diff
data$authen <- 8-data$authen
data$life_bw <- 8-data$life_bw
data$consq <- 8-data$consq

#overall
data$burden_tot <- data %>% select(rum:consq) %>% rowMeans(na.rm=T)
describe(data$burden_tot)
burden_tot <- data %>% select(rum:consq)
psych::alpha(burden_tot)

#subscales
data$daily <- data %>% select(rum:avoid_soc) %>% rowMeans(na.rm=T)
describe(data$daily)
dailyburd <- data %>% select(rum:avoid_soc)
psych::alpha(dailyburd)

data$extpull <- data %>% select(oblig:guilt) %>% rowMeans(na.rm=T)
describe(data$extpull)
extpull <- data %>% select(oblig:guilt)
psych::alpha(extpull)

data$harmrel <- data %>% select(distant:authen) %>% rowMeans(na.rm=T)
describe(data$harmrel)
harmrel <- data %>% select(distant:authen)
psych::alpha(harmrel)

data$antcnsq <- data %>% select(uncomf_convo:consq) %>% rowMeans(na.rm=T)
describe(data$antcnsq)
antcnsq <- data %>% select(uncomf_convo:consq)
psych::alpha(antcnsq)

data$overallburdn <- data %>% select(rum:consq) %>% rowMeans(na.rm=T)
describe(data$overallburdn)
overallburdn <- data %>% select(rum:consq)
psych::alpha(overallburdn) #.85
```

### Two-Step Regression - ALL PARTICIPANTS
```{r}
#Effects on Flourishing
cor.test(data$flourish, data$T2flourish)

mod1 <- lm(T2flourish~daily, data)
summary(mod1)
mod2 <- lm(T2flourish~harmrel,data)
summary(mod2)
mod3 <- lm(T2flourish~extpull,data)
summary(mod3)
mod4 <- lm(T2flourish~antcnsq,data)
summary(mod4)
mod5 <- lm(T2flourish~overallburdn, data)
summary(mod5)

mod1 <- lm(T2flourish~daily+flourish, data)
summary(mod1)
mod2 <- lm(T2flourish~harmrel+flourish,data)
summary(mod2)
mod3 <- lm(T2flourish~extpull+flourish,data)
summary(mod3)
mod4 <- lm(T2flourish~antcnsq+flourish,data)
summary(mod4)
mod5 <- lm(T2flourish~overallburdn+flourish, data)
summary(mod5)

#Effects on Anxiety
cor.test(data$anxious, data$T2anxious)

mod1 <- lm(T2anxious~daily, data)
summary(mod1)
mod2 <- lm(T2anxious~harmrel,data)
summary(mod2)
mod3 <- lm(T2anxious~extpull,data)
summary(mod3)
mod4 <- lm(T2anxious~antcnsq,data)
summary(mod4)
mod5 <- lm(T2anxious~overallburdn,data)
summary(mod5)

mod1 <- lm(T2anxious~daily+anxious, data)
summary(mod1)
mod2 <- lm(T2anxious~harmrel+anxious,data)
summary(mod2)
mod3 <- lm(T2anxious~extpull+anxious,data)
summary(mod3)
mod4 <- lm(T2anxious~antcnsq+anxious,data)
summary(mod4)
mod5 <- lm(T2anxious~overallburdn+anxious,data)
summary(mod5)

#Effects on Depression
cor.test(data$depress, data$T2depress)

mod1 <- lm(T2depress~daily, data)
summary(mod1)
mod2 <- lm(T2depress~harmrel,data)
summary(mod2)
mod3 <- lm(T2depress~extpull,data)
summary(mod3)
mod4 <- lm(T2depress~antcnsq,data)
summary(mod4)
mod5 <- lm(T2depress~overallburdn,data)
summary(mod5)

mod1 <- lm(T2depress~daily+depress, data)
summary(mod1)
mod2 <- lm(T2depress~harmrel+depress,data)
summary(mod2)
mod3 <- lm(T2depress~extpull+depress,data)
summary(mod3)
mod4 <- lm(T2depress~antcnsq+depress,data)
summary(mod4)
mod5 <- lm(T2depress ~overallburdn+depress,data)
summary(mod5)

#Effects on Relationship Satisfaction
cor.test(data$relsatis, data$T2relsatis)

mod1 <- lm(T2relsatis~daily+relsatis, data)
summary(mod1)
mod2 <- lm(T2relsatis~harmrel+relsatis,data)
summary(mod2)
mod3 <- lm(T2relsatis~extpull+relsatis,data)
summary(mod3)
mod4 <- lm(T2relsatis~antcnsq+relsatis,data)
summary(mod4)

#Effects on Authenticity
cor.test(data$authenscale, data$T2authenscale)

mod1 <- lm(T2authenscale~daily, data)
summary(mod1)
mod2 <- lm(T2authenscale~harmrel,data)
summary(mod2)
mod3 <- lm(T2authenscale~extpull,data)
summary(mod3)
mod4 <- lm(T2authenscale~antcnsq,data)
summary(mod4)
mod5 <- lm(T2authenscale~overallburdn, data)
summary(mod5)

mod1 <- lm(T2authenscale~daily+authenscale, data)
summary(mod1)
mod2 <- lm(T2authenscale~harmrel+authenscale,data)
summary(mod2)
mod3 <- lm(T2authenscale~extpull+authenscale,data)
summary(mod3)
mod4 <- lm(T2authenscale~antcnsq+authenscale,data)
summary(mod4)
mod5 <- lm(T2authenscale~overallburdn+authenscale, data)
summary(mod5)

```

### Filtering by Reveal Status
```{r}
#counts
table(data$T2reveal_others)
table(data$T2reveal_target)
table(data$T2reveal_others, data$T2reveal_target)

dat <- data %>% filter(T2reveal_target==2) #did not reveal to target
dat2 <- dat %>% filter(T2reveal_others==2) #did not reveal to orders

data$reveal <- ifelse(data$T2reveal_target != 2, 1, 0) #0=no reveal at all, 1 =total or partial reveal to target
table(data$reveal)
data$reveal2 <- ifelse(data$T2reveal_others != 2, 1, 0) #0=no reveal at all, 1 =total or partial reveal to others
table(data$reveal2)
data$reveal3 <- ifelse(data$reveal==0 & data$reveal2==0, 0, 1) #0 = no reveal to anyone, 1=some form of reveal to someone
table(data$reveal3)
data$reveal3 <- data$reveal3 %>% as.factor()
data$reveal2 <- data$reveal2 %>% as.factor()
data$reveal <- data$reveal %>% as.factor
```

### Item means & correlations w/scale for secret-kept sample
```{r}
dat %>% select(T2authenscale, T2flourish, T2anxious, T2depress, T2intimacy_1, T2relsatis) %>% describe()

cor.test(dat$T2anxious, dat$daily)
cor.test(dat$T2anxious, dat$harmrel)
cor.test(dat$T2anxious, dat$extpull)
cor.test(dat$T2anxious, dat$antcnsq)
cor.test(dat$T2anxious, dat$overallburdn)

cor.test(dat$T2depress, dat$daily)
cor.test(dat$T2depress, dat$harmrel)
cor.test(dat$T2depress, dat$extpull)
cor.test(dat$T2depress, dat$antcnsq)
cor.test(dat$T2depress, dat$overallburdn)

cor.test(dat$T2flourish, dat$daily)
cor.test(dat$T2flourish, dat$harmrel)
cor.test(dat$T2flourish, dat$extpull)
cor.test(dat$T2flourish, dat$antcnsq)
cor.test(dat$T2flourish, dat$overallburdn)

cor.test(dat$T2authenscale, dat$daily)
cor.test(dat$T2authenscale, dat$harmrel)
cor.test(dat$T2authenscale, dat$extpull)
cor.test(dat$T2authenscale, dat$antcnsq)
cor.test(dat$T2authenscale, dat$overallburdn)

cor.test(dat$T2intimacy_1, dat$daily)
cor.test(dat$T2intimacy_1, dat$harmrel)
cor.test(dat$T2intimacy_1, dat$extpull)
cor.test(dat$T2intimacy_1, dat$antcnsq)
cor.test(dat$T2intimacy_1, dat$overallburdn)

cor.test(dat$T2relsatis, dat$daily)
cor.test(dat$T2relsatis, dat$harmrel)
cor.test(dat$T2relsatis, dat$extpull)
cor.test(dat$T2relsatis, dat$antcnsq)
cor.test(dat$T2relsatis, dat$overallburdn)

#T1 T2 correlations for outcomes
cor.test(dat$authenscale, dat$T2authenscale) #r=.523, p<.001
cor.test(dat$anxious, dat$T2anxious) #r=.648, p<.001
cor.test(dat$depress, dat$T2depress) #r=.740, p<.001
cor.test(dat$flourish, dat$T2flourish) #r=.848, p<.001
cor.test(dat$relsatis, dat$T2relsatis) #r=.843, p<.001
cor.test(dat$intimacy_1, dat$T2intimacy_1) #r=.752, p<.001

#moderators
cor.test(dat$T2authenscale, dat$FNE)
cor.test(dat$T2authenscale, dat$socsup)
cor.test(dat$T2anxious, dat$FNE)
cor.test(dat$T2anxious, dat$socsup)
cor.test(dat$T2depress, dat$FNE)
cor.test(dat$T2depress, dat$socsup)
cor.test(dat$T2flourish, dat$FNE)
cor.test(dat$T2flourish, dat$socsup)
cor.test(dat$T2relsatis, dat$FNE)
cor.test(dat$T2relsatis, dat$socsup)
cor.test(dat$T2intimacy_1, dat$FNE)
cor.test(dat$T2intimacy_1, dat$socsup)
```

### Re-analyzing with only secret-kept from target people
```{r}
cor.test(dat$authenscale, dat$T2authenscale)

mod1 <- lm(T2authenscale~daily+authenscale, dat)
summary(mod1)
confint(mod1, level=0.95)
mod2 <- lm(T2authenscale~harmrel+authenscale,dat)
summary(mod2)
confint(mod2, level=0.95)
mod3 <- lm(T2authenscale~extpull+authenscale,dat)
summary(mod3)
confint(mod3, level=0.95)
mod4 <- lm(T2authenscale~antcnsq+authenscale,dat)
summary(mod4)
confint(mod4, level=0.95)
mod5 <- lm(T2authenscale~overallburdn+authenscale,dat)
summary(mod5)
confint(mod5, level=0.95)

cor.test(dat$depress, dat$T2depress)

mod1 <- lm(T2depress~daily+depress, dat)
summary(mod1)
confint(mod1, level=0.95)
mod2 <- lm(T2depress~harmrel+depress,dat)
summary(mod2)
confint(mod2, level=0.95)
mod3 <- lm(T2depress~extpull+depress,dat)
summary(mod3)
confint(mod3, level=0.95)
mod4 <- lm(T2depress~antcnsq+depress,dat)
summary(mod4)
confint(mod4, level=0.95)
mod5 <- lm(T2depress~overallburdn+depress,dat)
summary(mod5)
confint(mod5, level=0.95)

#Effects on Flourishing
cor.test(dat$flourish, dat$T2flourish)

mod1 <- lm(T2flourish~daily, dat)
summary(mod1)
mod2 <- lm(T2flourish~harmrel,dat)
summary(mod2)
mod3 <- lm(T2flourish~extpull,dat)
summary(mod3)
mod4 <- lm(T2flourish~antcnsq,dat)
summary(mod4)

#Effects on Anxiety
cor.test(dat$anxious, dat$T2anxious)

mod1 <- lm(T2anxious~daily+anxious, dat)
summary(mod1)
confint(mod1, level=0.95)
mod2 <- lm(T2anxious~harmrel+anxious,dat)
summary(mod2)
confint(mod2, level=0.95)
mod3 <- lm(T2anxious~extpull+anxious,dat)
summary(mod3)
confint(mod3, level=0.95)
mod4 <- lm(T2anxious~antcnsq+anxious,dat)
summary(mod4)
confint(mod4, level=0.95)
mod5 <- lm(T2anxious~overallburdn+anxious,dat)
summary(mod5)
confint(mod5, level=0.95)
```


### Re-analyzing with only secret-kept from target & otherspeople
```{r}
cor.test(dat2$authenscale, dat2$T2authenscale)

mod1 <- lm(T2authenscale~daily+authenscale, dat2)
summary(mod1)
mod2 <- lm(T2authenscale~harmrel+authenscale,dat2)
summary(mod2)
mod3 <- lm(T2authenscale~extpull+authenscale,dat2)
summary(mod3)
mod4 <- lm(T2authenscale~antcnsq+authenscale,dat2)
summary(mod4)

cor.test(dat2$depress, dat2$T2depress)

mod1 <- lm(T2depress~daily+depress, dat2)
summary(mod1)
mod2 <- lm(T2depress~harmrel+depress,dat2)
summary(mod2)
mod3 <- lm(T2depress~extpull+depress,dat2)
summary(mod3)
mod4 <- lm(T2depress~antcnsq+depress,dat2)
summary(mod4)

#Effects on Flourishing
cor.test(dat2$flourish, dat2$T2flourish)

mod1 <- lm(T2flourish~daily, dat2)
summary(mod1)
mod2 <- lm(T2flourish~harmrel,dat2)
summary(mod2)
mod3 <- lm(T2flourish~extpull,dat2)
summary(mod3)
mod4 <- lm(T2flourish~antcnsq,dat2)
summary(mod4)

#Effects on Anxiety
cor.test(dat2$anxious, dat2$T2anxious)

mod1 <- lm(T2anxious~daily+anxious, dat2)
summary(mod1)
mod2 <- lm(T2anxious~harmrel+anxious,dat2)
summary(mod2)
mod3 <- lm(T2anxious~extpull+anxious,dat2)
summary(mod3)
mod4 <- lm(T2anxious~antcnsq+anxious,dat2)
summary(mod4)

```


### Adding potential moderators
```{r}
cor.test(data$FNE,data$depress)
cor.test(data$FNE,data$anxious)
cor.test(data$FNE,data$authenscale) #all signif

cor.test(data$FNE, data$daily) #r=.197, p=.006
cor.test(data$FNE, data$antcnsq) #r=.158, p=.029
cor.test(data$FNE, data$extpull) #r=.095, p=.193
cor.test(data$FNE, data$harmrel) #r=.081, p=.265

cor.test(data$socsup,data$depress)
cor.test(data$socsup,data$anxious)
cor.test(data$socsup,data$authenscale) #none signif

cor.test(data$socsup, data$daily) #r=-.003, p=.966
cor.test(data$socsup, data$antcnsq) #r=-.197, p=.006
cor.test(data$socsup, data$extpull) #r=.056, p=.441
cor.test(data$socsup, data$harmrel) #r=-.088, p=.234

#FNE for anxiety, FNE was signif for anxiety in all analyses, as was T1 anxiety
fne_mod1 <- lm(T2anxious~daily+anxious+FNE,data) #not signif as before
summary(fne_mod1)
fne_mod2 <- lm(T2anxious~harmrel+anxious+FNE,data) #still signif
summary(fne_mod2)
fne_mod3 <- lm(T2anxious~extpull+anxious+FNE,data) #not signif as before
summary(fne_mod3)
fne_mod4 <- lm(T2anxious~antcnsq+anxious+FNE,data) #marginal now
summary(fne_mod4)

#FNE*burden subscale interactions for anxiety
fne_mod5 <- lm(T2anxious~daily*FNE+anxious, dat) #anx signif, nothing else
summary(fne_mod5)
fne_mod6 <- lm(T2anxious~harmrel*FNE+anxious, dat) #anx signif, nothing else
summary(fne_mod6)
fne_mod7 <- lm(T2anxious~extpull*FNE+anxious, dat) #anx signif, nothing else
summary(fne_mod7)
fne_mod8 <- lm(T2anxious~antcnsq*FNE+anxious, dat) #anx signif, nothing else
summary(fne_mod8)
fne_mod9 <- lm(T2anxious~overallburdn*FNE+anxious, dat) #anx signif, nothing else
summary(fne_mod9)

#FNE for depression, FNE not signif in any analyses, all effects hold
fne_mod1 <- lm(T2depress~daily+depress+FNE,data) #still signif
summary(fne_mod1)
fne_mod2 <- lm(T2depress~harmrel+depress+FNE,data) #still signif
summary(fne_mod2)
fne_mod3 <- lm(T2depress~extpull+depress+FNE,data) #not signif as before
summary(fne_mod3)
fne_mod4 <- lm(T2depress~antcnsq+depress+FNE,data) #still signif
summary(fne_mod4)

#FNE*burden subscale interactions for depression
fne_mod5 <- lm(T2depress~daily*FNE+depress, dat) #depress signif, nothing else
summary(fne_mod5)
fne_mod6 <- lm(T2depress~harmrel*FNE+depress, dat) #depress signif, nothing else
summary(fne_mod6)
fne_mod7 <- lm(T2depress~extpull*FNE+depress, dat) #depress signif, nothing else
summary(fne_mod7)
fne_mod8 <- lm(T2depress~antcnsq*FNE+depress, dat) #depress signif, nothing else
summary(fne_mod8)
fne_mod9 <- lm(T2depress~overallburdn*FNE+depress, dat) #depress signif, nothing else
summary(fne_mod9)


#FNE for authenticity,FNE a signif predictor in all analyses, pattern generally holds
fne_mod1 <- lm(T2authenscale~daily+authenscale+FNE,data) #still signif
summary(fne_mod1)
fne_mod2 <- lm(T2authenscale~harmrel+authenscale+FNE,data) #still signif
summary(fne_mod2)
fne_mod3 <- lm(T2authenscale~extpull+authenscale+FNE,data) #not signif as before
summary(fne_mod3)
fne_mod4 <- lm(T2authenscale~antcnsq+authenscale+FNE,data) #cusp of marginal now
summary(fne_mod4)

#FNE*burden subscale interactions for authenticity
fne_mod5 <- lm(T2authenscale~daily*FNE+authenscale, dat) #authen signif, nothing else
summary(fne_mod5)
fne_mod6 <- lm(T2authenscale~harmrel*FNE+authenscale, dat) #authen signif, nothing else
summary(fne_mod6)
fne_mod7 <- lm(T2authenscale~extpull*FNE+authenscale, dat) #authen signif, nothing else
summary(fne_mod7)
fne_mod8 <- lm(T2authenscale~antcnsq*FNE+authenscale, dat) #authen signif, nothing else
summary(fne_mod8)
fne_mod9 <- lm(T2authenscale~overallburdn*FNE+authenscale, dat) #authen signif, nothing else
summary(fne_mod9)

#FNE*burden subscale interactions for flourish
fne_mod5 <- lm(T2flourish~daily*FNE+flourish, dat) #daily & daily*FNE marginal, FNE & flourish signif
summary(fne_mod5)
confint(fne_mod5, level=.95)

fne_mod6 <- lm(T2flourish~harmrel*FNE+flourish, dat) #FNE marginal, flourish signif
summary(fne_mod6)
confint(fne_mod6, level=.95)

fne_mod7 <- lm(T2flourish~extpull*FNE+flourish, dat) #FNE & flourish signif, interact marginal
summary(fne_mod7)
confint(fne_mod7, level=.95)
interact_plot(fne_mod7, pred = extpull, modx = FNE, centered="none", plot.points=TRUE, x.label="Pull to Reveal Burden", y.label="T2 Flourishing") + theme_apa()
sim_slopes(fne_mod7, pred = extpull, modx = FNE, johnson_neyman = FALSE)


fne_mod8 <- lm(T2flourish~antcnsq*FNE+flourish, dat) #flourish signif, nothing else
summary(fne_mod8)
confint(fne_mod8, level=.95)

fne_mod9 <- lm(T2flourish~overallburdn*FNE+flourish, dat) #overall marginal, FNE flourish & interact signif
summary(fne_mod9)
interact_plot(fne_mod9, pred = overallburdn, modx = FNE, centered="none", plot.points=TRUE, x.label="Overall Burden", y.label="T2 Flourishing") + theme_apa()
confint(fne_mod9, level=.95)
library(sandwich)
sim_slopes(fne_mod9, pred = overallburdn, modx = FNE, johnson_neyman = FALSE)

#Exploring the socialsupport *burden harmrel interaction 
socsup1 <- lm(T2anxious~harmrel*socsup+anxious,data) #anxious signif, nothing else
summary(socsup1)
socsup2 <- lm(T2depress~harmrel*socsup+depress,data) #depress signif, nothing else
summary(socsup2)
socsup3 <- lm(T2authenscale~harmrel*socsup+authenscale,data) #authen signif, nothing else
summary(socsup3)

```

### Checking T1/T2 diffs in outcomes based on reveal status
```{r}
#repeated measures mixed ANOVA for T1/T2 diffs based on reveal status
#flourishing
data_long <- data %>% pivot_longer(cols=c('flourish', 'T2flourish'), names_to='time', values_to='outcome') 
data_long %>% group_by(time, reveal3) %>% get_summary_stats(outcome, type="mean_sd")
bxp <- ggboxplot(data_long,x="time",y="outcome", color="reveal3")
data_long %>% group_by(time) %>% levene_test(outcome~reveal3) #no homogeneity of variance at T2 (p=.03), yes at T1
flour.aov <- anova_test(data=data_long, dv=outcome, wid=ID, between=reveal3, within=time)
get_anova_table(flour.aov) #nothing signif

#depression
data_long <- data %>% pivot_longer(cols=c('depress', 'T2depress'), names_to='time', values_to='outcome')
data_long %>% group_by(time, reveal3) %>% get_summary_stats(outcome, type="mean_sd")
bxp <- ggboxplot(data_long,x="time",y="outcome", color="reveal3")
bxp
data_long %>% group_by(time) %>% levene_test(outcome~reveal3) #yes homogeneity of variance 
depr.aov <- anova_test(data=data_long, dv=outcome, wid=ID, between=reveal3, within=time)
get_anova_table(depr.aov) #signif effect of time, no interaction, lower depress at T2

#anxiety
data_long <- data %>% pivot_longer(cols=c('anxious', 'T2anxious'), names_to='time', values_to='outcome')
data_long %>% group_by(time, reveal3) %>% get_summary_stats(outcome, type="mean_sd")
bxp <- ggboxplot(data_long,x="time",y="outcome", color="reveal3")
bxp
data_long %>% group_by(time) %>% levene_test(outcome~reveal3) #yes homogeneity of variance 
anx.aov <- anova_test(data=data_long, dv=outcome, wid=ID, between=reveal3, within=time)
get_anova_table(anx.aov) #nothing signif

#authenticity
data_long <- data %>% pivot_longer(cols=c('authenscale', 'T2authenscale'), names_to='time', values_to='outcome')
data_long %>% group_by(time, reveal3) %>% get_summary_stats(outcome, type="mean_sd")
bxp <- ggboxplot(data_long,x="time",y="outcome", color="reveal3")
bxp
data_long %>% group_by(time) %>% levene_test(outcome~reveal3) #yes homogeneity of variance 
authen.aov <- anova_test(data=data_long, dv=outcome, wid=ID, between=reveal3, within=time)
get_anova_table(authen.aov) #nothing signif

#rel satisf
data_long <- data %>% pivot_longer(cols=c('relsatis', 'T2relsatis'), names_to='time', values_to='outcome')
data_long %>% group_by(time, reveal3) %>% get_summary_stats(outcome, type="mean_sd")
bxp <- ggboxplot(data_long,x="time",y="outcome", color="reveal3")
bxp
data_long %>% group_by(time) %>% levene_test(outcome~reveal3) #yes homogeneity of variance 
rel.aov <- anova_test(data=data_long, dv=outcome, wid=ID, between=reveal3, within=time)
get_anova_table(rel.aov) #time almost signif (p=.058), no interactions, lower at T2

#intimacy
data_long <- data %>% pivot_longer(cols=c('intimacy_1', 'T2intimacy_1'), names_to='time', values_to='outcome')
data_long %>% group_by(time, reveal3) %>% get_summary_stats(outcome, type="mean_sd")
bxp <- ggboxplot(data_long,x="time",y="outcome", color="reveal3")
bxp
data_long %>% group_by(time) %>% levene_test(outcome~reveal3) #yes homogeneity of variance 
close.aov <- anova_test(data=data_long, dv=outcome, wid=ID, between=reveal3, within=time)
get_anova_table(close.aov) #nothing signif

test <- aov(antcnsq~reveal3,data) #signif
summary(test)

test <- aov(harmrel~reveal3,data) #not signif
summary(test)

test <- aov(daily~reveal3,data) #not signif
summary(test)

test <- aov(extpull~reveal3,data) #not signif
summary(test)

test <- aov(overallburdn~reveal3,data) #not signif
summary(test)
```

### Adding secret-reveal status as predictor/interaction term
```{r}
#Depression
rmod1 <- lm(T2depress~daily*reveal3 + depress,data) 
summary(rmod1)
rmod2 <- lm(T2depress~antcnsq*reveal3 + depress,data) 
summary(rmod2)
rmod3 <- lm(T2depress~harmrel*reveal3 + depress,data) 
summary(rmod3)
rmod4 <- lm(T2depress~extpull*reveal3 + depress,data) 
summary(rmod4)
rmod5 <- lm(T2depress~overallburdn*reveal3 + depress,data)
summary(rmod5)


#Anxiety
rmod1 <- lm(T2anxious~daily*reveal3 + anxious,data) 
summary(rmod1)
rmod2 <- lm(T2anxious~antcnsq*reveal3 + anxious,data) 
summary(rmod2)
rmod3 <- lm(T2anxious~harmrel*reveal3 + anxious,data) 
summary(rmod3)
rmod4 <- lm(T2anxious~extpull*reveal3 + anxious,data) 
summary(rmod4)
rmod5 <- lm(T2anxious~overallburdn*reveal3 + anxious,data)
summary(rmod5)


#Authenticity
rmod1 <- lm(T2authenscale~daily*reveal3 + authenscale,data) 
summary(rmod1)
rmod2 <- lm(T2authenscale~antcnsq*reveal3 + authenscale,data) #marginal interaction
summary(rmod2)
confint(rmod2, level=0.95)
interact_plot(rmod2, pred = antcnsq, modx = reveal3, centered="none", plot.points=TRUE, x.label="Anticipated Consequences Burden", y.label="T2 Authenticity") + theme_apa()
sim_slopes(rmod2, pred = antcnsq, modx = reveal3, johnson_neyman = FALSE)

rmod3 <- lm(T2authenscale~harmrel*reveal3 + authenscale,data) #main effect +marginal interaction
summary(rmod3)
confint(rmod3, level=0.95)
interact_plot(rmod3, pred = harmrel, modx = reveal3, centered="none", plot.points=TRUE, x.label="Harm to Relationships Burden", y.label="T2 Authenticity") + theme_apa()
sim_slopes(rmod3, pred = harmrel, modx = reveal3, johnson_neyman = FALSE)
rmod4 <- lm(T2authenscale~extpull*reveal3 + authenscale,data) 
summary(rmod4)
rmod5 <- lm(T2authenscale~overallburdn*reveal3 + authenscale,data)
summary(rmod5)

rmod1 <- lm(T2flourish~daily*reveal3 + flourish,data) 
summary(rmod1)
rmod2 <- lm(T2flourish~antcnsq*reveal3 + flourish,data) 
summary(rmod2)
rmod3 <- lm(T2flourish~harmrel*reveal3 + flourish,data) 
summary(rmod3)
rmod4 <- lm(T2flourish~extpull*reveal3 + flourish,data) #main effects and signif interaction
summary(rmod4)
confint(rmod4, level=0.95)
interact_plot(rmod4, pred = extpull, modx = reveal3, centered="none", plot.points=TRUE, x.label="Pull to Reveal Burden", y.label="T2 Flourishing") + theme_apa()
sim_slopes(rmod4, pred = extpull, modx = reveal3, johnson_neyman = FALSE)
rmod5 <- lm(T2flourish~overallburdn*reveal3 + flourish,data)
summary(rmod5)

#Exploring the interactions for authenticity
#anticipated consequences burden
ggplot(data, aes(x=antcnsq, y=T2authenscale, group=reveal3, color=reveal3)) + geom_smooth(method="lm") + geom_point() + theme_bw()
data %>% group_by(reveal3) %>% anova_test(T2authenscale ~antcnsq+authenscale)
dat3 <- data %>% filter(reveal3==1)
rmod2a <- lm(T2authenscale~antcnsq + authenscale,dat3) #both + and signif
summary(rmod2a)
rmod2b <- lm(T2authenscale~antcnsq+authenscale, dat2) #only authenscale positive
summary(rmod2b)


#harm to relationships burden
ggplot(data, aes(x=harmrel, y=T2authenscale, group=reveal3, color=reveal3)) + geom_smooth(method="lm") + geom_point() + theme_bw()

data %>% group_by(reveal3) %>% anova_test(T2authenscale ~harmrel+authenscale)
rmod3a <- lm(T2authenscale~harmrel + authenscale,dat3)  #only authenscale signif
summary(rmod3a)
rmod3b <- lm(T2authenscale~harmrel+authenscale, dat2) #both harmrel & authenscale signif and positive
summary(rmod3b)


```

### Checking for T1/T2 mean differences
```{r}
t.test(data$authenscale, data$T2authenscale) #no diff, 3.33 vs 3.34
t.test(data$anxious, data$T2anxious) #no diff, 3.33 vs 3.19
t.test(data$depress, data$T2depress) #no diff, 3.97 vs 3.74
t.test(data$flourish, data$T2flourish) #no diff, 4.99 vs 4.94
t.test(data$relsatis, data$T2relsatis) #no diff, 4.73 vs. 4.63
t.test(data$intimacy_1, data$T2intimacy_1) #no diff, 6.86 vs. 6.60

```



